#include "ProgramEntry.h"

using namespace OBR;

ProgramEntry::ProgramEntry(std::string cuda_source_path) : program_desc({}), program_opt({})
{
    this->cuda_module = CudaModule::getModule(cuda_source_path);
}

ProgramEntry::~ProgramEntry()
{
}

void ProgramEntry::linkProgram(OptixDeviceContext &ctx,
                               OptixPipelineCompileOptions &pipeline_compile_options)
{
    this->cuda_module->link(ctx, pipeline_compile_options);

    OptixProgramGroupOptions &opt = this->getProgramGroupOptions();
    OptixProgramGroupDesc &desc = this->getProgramGroupDesc();

    this->setProgram(std::make_shared<CudaProgram>(ctx, pipeline_compile_options, opt, desc));
}

// this interface may not be used in some classes
void ProgramEntry::uploadSbtData()
{
}

// this interface may not be used in some classes
void ProgramEntry::updateSbtData()
{
}

// this interface may not be used in some classes
CUdeviceptr ProgramEntry::getSbtDevicePtr()
{
    return this->sbt_data.d_pointer();
}